import '../public.dart';

class ChapterModel extends ViewStateModel {
  ThemeModel themeModel;
  ChapterModel(this.themeModel);
  String title;
  String url;
  String author;
  String now;
  String reptileType;
  String reptileType1;
  BookInfo bookInfo = new BookInfo();
  List<Chapter> chapterList;
  initData({
    String title,
    String url,
    String author,
    String now,
    String reptileType,
    String reptileType1,
  }) async {
    setBusy(true);
    EventBus().on("setChapterList", (arg) {
      chapterList = arg;
      setBusy(false);
      notifyListeners();
    });
  }

  Chapter findChapter() {
    Chapter chapter;
    if (int.parse(now) > 0 && bookInfo.list.length >= int.parse(now)) {
      chapter = bookInfo.list[int.parse(now)];
    } else {
      chapter = bookInfo.list[0];
    }
    return chapter;
  }
}
